﻿using MediatR;
using Traceability.Commont.Domains.AnimalsDomainFiles;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.AdmissionRegistrationFile
{
    /// <summary>
    /// 商品代号添加
    /// </summary>
    public class ShopCreateHander : IRequestHandler<ShopCreateCommand, Resqults>
    {
        private readonly IBateRepository<Shopping> shop;

        public ShopCreateHander(IBateRepository<Shopping> shop)
        {
            this.shop = shop;
        }

        public async Task<Resqults> Handle(ShopCreateCommand request, CancellationToken cancellationToken)
        {
            try
            {
                Resqults res = new Resqults() { Code = 0 };
                Shopping shopping = new Shopping();
                shopping.ShoppingDesignationName=request.ShoppingDesignationName;
                shopping.Unit=request.Unit;
                shopping.Sku = request.Sku;
                shopping.Tablereport = request.Tablereport;
                res.Code = await shop.Add(shopping);
                if (res.Code > 0)
                {
                    res.Messges = "成功";
                }
                return res;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
